package cn.lhjl.day07.practice;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class 计算字符串中每个字符出现次数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入字符串");
        String str = scanner.next();
        char[] chars = str.toCharArray();
        char c;
        Map<Character,Integer> map = new HashMap<>();
        for (int i = 0; i < chars.length; i++) {
            c=chars[i];
            if (map.containsKey(c)){
                Integer value = map.get(c);
                value++;
                map.put(c,value);
            }else {
                map.put(c,1);
            }
        }
        System.out.println(map);


    }
}
